class Solution(object):
    def checkArithmeticSubarrays(self, nums, l, r):
        n = len(nums)
        m = len(l)
        ans = [True] * m
        for i in range(m):
            t = nums[l[i]: r[i] + 1]
            t.sort()
            for j in range(1, len(t)):
                if t[j] - t[j - 1] != t[1] - t[0]:
                    ans[i] = False
                    break
        return ans



data = Solution()
nums = [4, 6, 5, 9, 3, 7]
l = [0, 0, 2]
r = [2, 3, 5]
print(data.checkArithmeticSubarrays(nums, l, r))
